<!doctype html>
<html lang="en">
 <head> 
  <meta charset="UTF-8"> 
  <meta name="description" content="燎火的个人博客"> 
  <meta name="keyword" content="燎火,qq799378666,软件开发,java,c#,js,html,html5,css"> 
  <title>Centos7下完美安装并配置mysql5.6</title> 
  <script src="/js/jquery-1.11.1.min.js"></script> 
  <script src="/js/bootstrap-3.3.5/js/bootstrap.js"></script> 
  <link href="/js/bootstrap-3.3.5/css/bootstrap.css" rel="stylesheet"> 
  <script src="/js/base.js"></script> 
  <script src="/js/nav.js"></script> 
  <script src="/js/jquery.toTop.min.js"></script> 
  <link href="/style/article.css" rel="stylesheet"> 
 </head> 
 <body> 
  <div id="main"> 
   <h3 id="title">Centos7下完美安装并配置mysql5.6</h3> 
   <div id="content">
    <blockquote style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; position: relative; font-size: 1.5rem; background: rgb(244, 244, 244); margin: 20px 0px; padding: 16px 24px 16px 35px; font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal;">
     <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; line-height: 22.5px;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; color: rgb(136, 136, 136); font-family: &quot;Microsoft YaHei&quot;; font-size: 12px;">Centos7将默认数据库mysql替换成了Mariadb，对于我们这些还想用mysql的人来说并不是一个好消息。</span></p>
     <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; line-height: 22.5px;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-size: 12px; font-family: &quot;Microsoft YaHei&quot;; color: rgb(136, 136, 136);">最近我搜罗了网上各种安装教程，各种出问题，要么安装失败，要么安装成功了却使用不了mysql。今天终于大功告成，所以赶快分享一下，好了话不多说，开始吧！</span></p>
    </blockquote>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; background-color: rgb(0, 176, 80);"><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">一、安装MySQL</strong></span><br></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">1、下载安装包mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz</span></p>
    <blockquote style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; position: relative; font-size: 1.5rem; background: rgb(244, 244, 244); margin: 20px 0px; padding: 16px 24px 16px 35px; font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal;">
     <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px;"><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; color: rgb(255, 0, 0);">&gt;&gt;&gt; 下载地址失效后请大家及时通知，我会第一时间更新新的地址&lt;&lt;&lt;&lt;</span></strong></p>
     <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px;"><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">快速通道：</span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;times new roman&quot;;"></span><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: 微软雅黑, &quot;Microsoft YaHei&quot;;">&nbsp;</span></strong><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: 微软雅黑, &quot;Microsoft YaHei&quot;;"><a href="https://yunpan.cn/cY82qJVCkrnEy" target="_blank" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; border: none; outline: 0px; transition: color 0.3s; text-decoration: none; color: rgb(68, 102, 187);">https://yunpan.cn/cY82qJVCkrnEy&nbsp;</a>&nbsp;</span></strong><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: 微软雅黑, &quot;Microsoft YaHei&quot;;"><em style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"></em>（访问密码： f0a7）</span></strong></p>
    </blockquote>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">&nbsp;</span><br></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; line-height: 1.5; font-family: &quot;Microsoft YaHei&quot;;">2、卸载系统自带的Mariadb(如果系统没有mariadb就直接跳过这步)</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">#查询出已安装的mariadb[root@localhost~]#&nbsp;rmp&nbsp;-qa|grep&nbsp;mariadb#卸载[root@localhost~]#&nbsp;pm&nbsp;-e&nbsp;--nodeps&nbsp;文件名</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">3、删除etc目录下的my.cnf文件（最好对以前的my.cnf文件做个备份:shell&gt;<strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">cp /etc/my.cnf /etc/my.cnf.bak</strong>）</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost~]#&nbsp;rm&nbsp;/etc/my.cnf</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">4、 执行以下命令来创建mysql用户组</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost~]#&nbsp;groupadd&nbsp;mysql</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; line-height: 1.5; font-family: &quot;Microsoft YaHei&quot;;">5、执行以下命令来创建一个用户名为mysql的用户并加入mysql用户组</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;~]#&nbsp;useradd&nbsp;-g&nbsp;mysql&nbsp;mysql</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; line-height: 1.5; font-family: &quot;Microsoft YaHei&quot;;">6、将下载的二进制压缩包放到/usr/local/目录下。</span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; line-height: 1.5; font-family: &quot;Microsoft YaHei&quot;;">7、解压安装包</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs css" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;~]#&nbsp;tar&nbsp;-zxvf&nbsp;mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">8、将解压好的文件夹重命名为mysql</span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">9、在etc下新建配置文件my.cnf，并在该文件内添加以下代码：</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs makefile" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[mysql]&nbsp;#&nbsp;设置mysql客户端默认字符集&nbsp;default-character-set=utf8&nbsp;
socket=/tmp/mysql.sock&nbsp;
[mysqld]&nbsp;
skip-name-resolve&nbsp;#&nbsp;设置3306端口&nbsp;port&nbsp;=&nbsp;3306&nbsp;
socket=/tmp/mysql.sock&nbsp;#&nbsp;设置mysql的安装目录&nbsp;basedir=/usr/local/mysql&nbsp;#&nbsp;设置mysql数据库的数据的存放目录&nbsp;datadir=/usr/local/mysql/data&nbsp;#&nbsp;允许最大连接数&nbsp;max_connections=200&nbsp;#&nbsp;服务端使用的字符集默认为8比特编码的latin1字符集&nbsp;character-set-server=utf8&nbsp;#&nbsp;创建新表时将使用的默认存储引擎&nbsp;default-storage-engine=INNODB&nbsp;
lower_case_table_names=1&nbsp;
max_allowed_packet=16M</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">10、进入安装mysql软件目录</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;~]#&nbsp;cd&nbsp;/usr/local/mysql&nbsp;[root@localhost&nbsp;mysql]#&nbsp;chown&nbsp;-R&nbsp;mysql:mysql&nbsp;./　　#&nbsp;修改当前目录拥有者为mysql用户&nbsp;[root@localhost&nbsp;mysql]#&nbsp;./scripts/mysql_install_db&nbsp;--user=mysql&nbsp;#&nbsp;安装数据库&nbsp;[root@localhost&nbsp;mysql]#&nbsp;chown&nbsp;-R&nbsp;mysql:mysql&nbsp;data&nbsp;修改当前data目录拥有者为mysql用户</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">&nbsp;</span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">到此数据库安装完毕！</span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;"><br></span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; background-color: rgb(0, 176, 80);"><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;">二、配置MySQL</strong></span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">1、授予my.cnf的最大权限。</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;~]#&nbsp;chown&nbsp;777&nbsp;/etc/my.cnf</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">设置开机自启动服务控制脚本：</span></p>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">2、复制启动脚本到资源目录</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs gradle" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;cp&nbsp;./support-files/mysql.server&nbsp;/etc/rc.d/init.d/mysqld</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">3、增加mysqld服务控制脚本执行权限</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;chmod&nbsp;+x&nbsp;/etc/rc.d/init.d/mysqld</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">4、将mysqld服务加入到系统服务</span></p>
    <pre class="brush:html;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;chkconfig&nbsp;--add&nbsp;mysqld</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">5、检查mysqld服务是否已经生效</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;chkconfig&nbsp;--list&nbsp;mysqld</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><strong style="box-sizing: inherit; -webkit-tap-highlight-color: transparent;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5; background-color: rgb(255, 255, 255);">命令输出类似下面的结果：</span></strong></p>
    <blockquote style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; position: relative; font-size: 1.5rem; background: rgb(244, 244, 244); margin: 20px 0px; padding: 16px 24px 16px 35px; font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal;">
     <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px;"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; background-color: rgb(255, 255, 255);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off</span><br><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">表明mysqld服务已经生效，在2、3、4、5运行级别随系统启动而自动启动，以后可以使用service命令控制mysql的启动和停止。</span></span></p>
    </blockquote>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">6、启动msql（停止mysqld服务：service mysqld stop）</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;service&nbsp;mysqld&nbsp;start</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">7、将mysql的bin目录加入PATH环境变量，编辑/etc/profile文件</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;vi&nbsp;/etc/profile</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">在文件最后添加如下信息：</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;export&nbsp;PATH=$PATH:/usr/local/mysql/bin</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">执行下面的命令使所做的更改生效：</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;.&nbsp;/etc/profile</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">8、以root账户登陆mysql，默认是没有密码</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;mysql&nbsp;-u&nbsp;root&nbsp;-p</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;; line-height: 1.5;">9、设置root账户密码 注意下面的you password改成你的要修改的密码</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs actionscript" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">mysql&gt;&nbsp;use&nbsp;mysql&nbsp;use&nbsp;mysql&nbsp;
mysql&gt;&nbsp;update&nbsp;user&nbsp;set&nbsp;password=password('you&nbsp;password')&nbsp;where&nbsp;user='root'&nbsp;and&nbsp;host='localhost';</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">10、设置远程主机登录（我用的是Navicat）注意下面的your username 和 your password改成你需要设置的用户和密码</span></p>
    <pre class="brush:xml;toolbar: true; auto-links: false; hljs elixir" style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; overflow-x: auto; padding: 2px; background-color: rgb(63, 63, 63); color: rgb(220, 220, 220); border-radius: 3px; line-height: 1.4; word-wrap: normal; font-size: 13px; font-family: Menlo, Monaco, Consolas, &quot;Courier New&quot;, monospace;">[root@localhost&nbsp;mysql]#&nbsp;GRANT&nbsp;ALL&nbsp;PRIVILEGES&nbsp;ON&nbsp;*.*&nbsp;TO&nbsp;'your&nbsp;username'@'%'&nbsp;IDENTIFIED&nbsp;BY&nbsp;'your&nbsp;password'&nbsp;WITH&nbsp;GRANT&nbsp;OPTION;</pre>
    <p style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; margin-bottom: 16px; color: rgb(61, 70, 77); font-family: &quot;Pingfang SC&quot;, STHeiti, &quot;Lantinghei SC&quot;, &quot;Open Sans&quot;, Arial, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, &quot;WenQuanYi Micro Hei&quot;, SimSun, sans-serif; white-space: normal; background-color: rgb(248, 248, 248);"><span style="box-sizing: inherit; -webkit-tap-highlight-color: transparent; font-family: &quot;Microsoft YaHei&quot;;">&nbsp;</span></p>
    <p><br></p>
   </div> 
  </div>  
 </body>
</html>